package com.koushikdutta.async.http;

import com.koushikdutta.async.AsyncSocket;
import com.koushikdutta.async.DataEmitter;
import com.koushikdutta.async.callback.ConnectCallback;
import com.koushikdutta.async.future.Cancellable;
import com.koushikdutta.async.http.libcore.ResponseHeaders;
import com.koushikdutta.async.util.UntypedHashtable;

public interface AsyncHttpClientMiddleware {

    public static class GetSocketData {
        public ConnectCallback connectCallback;
        public AsyncHttpRequest request;
        public Cancellable socketCancellable;
        public UntypedHashtable state = new UntypedHashtable();
    }

    public static class OnSocketData extends GetSocketData {
        public AsyncSocket socket;
    }

    public static class OnHeadersReceivedData extends OnSocketData {
        public ResponseHeaders headers;
    }

    public static class OnBodyData extends OnHeadersReceivedData {
        public DataEmitter bodyEmitter;
    }

    public static class OnRequestCompleteData extends OnBodyData {
        public Exception exception;
    }

    Cancellable getSocket(GetSocketData getSocketData);

    void onBodyDecoder(OnBodyData onBodyData);

    void onHeadersReceived(OnHeadersReceivedData onHeadersReceivedData);

    void onRequestComplete(OnRequestCompleteData onRequestCompleteData);

    void onSocket(OnSocketData onSocketData);
}
